package Messages;

import java.io.Serializable;

import General.Hash;


/**
 * Modify message -file change
 * @author Guy &Liel
 *
 */
public class FileChangeMsg implements Serializable, Msg {

	MsgType type;
	String fileHash;
	String fileName;
	String folder;
	private String fileFullPath;
	
	private static final long serialVersionUID = 1L;
	/**
	 * Change message constructor
	 * @param type
	 * @param fileCheckSum
	 * @param fileName
	 * @param folder
	 * @param fullPath
	 */
	public FileChangeMsg(MsgType type, String fileCheckSum, String fileName, String folder,String fullPath){//, ClientDetails cd) {
		this.type = type;
		this.fileFullPath = fullPath;
		this.fileHash = fileCheckSum;
		this.fileName = fileName;
		this.folder = folder;
		System.out.println("##########    " + this.folder);
	}
	@Override
	/**
	 * get message type
	 */
	public MsgType getType() {
		return this.type;
	}
	/**
	 * get the check sum of the file
	 * @return the file check sum
	 */
	public String getFileHash() {
		if (fileHash==null){
			try {
				fileHash = Hash.getHashFile(fileFullPath);
			} catch (Exception e) {
				System.out.println("%%%%%%%%%%");
				// TODO Auto-generated catch block
				e.printStackTrace();
				
			}

		}
		return fileHash;
	}
	/**
	 * get file name
	 * @return String
	 */
	public String getFileName() {
		return fileName;
	}
	/**
	 * set file name
	 * @param fileName
	 */
	public void setFileName(String fileName) {
		this.fileName = fileName;
	}
	/**
	 * get name folder
	 * @return String
	 */
	public String getFolder() {
		return folder;
	}
	/**
	 * set name folder
	 * @param folder
	 */
	public void setFolder(String folder) {
		this.folder = folder;
	}
	/**
	 * get file path
	 * @return String
	 */
	public String getFileFullPath() {
		return fileFullPath;
	}

}
